package com.atguigu.srb.rabbitutil.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class MQService {
    private final AmqpTemplate amqpTemplate;

    public MQService(AmqpTemplate amqpTemplate) {
        this.amqpTemplate = amqpTemplate;
    }

    public boolean sendMessage(String exchange, String routingKey, Object message) {
        log.info("发送消息");
        amqpTemplate.convertAndSend(exchange, routingKey, message);
        return true;
    }
}
